/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.gui.client;

//import com.google.gwt.user.client.ui.*;
import nfse.gui.record.*;
import java.util.Vector;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.RegionPosition;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.*;
import com.gwtext.client.widgets.form.*;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;

public class EventDisplayDialog extends Window {

    boolean cancelled = false;

    FormPanel formPanel = new FormPanel();

    int type = -1;

    Label testLabel = new Label("test");

    Vector widgets = new Vector();

    public EventDisplayDialog() {

        this.setIconCls("pac-icon");
        this.setTitle("Event Viewer");

        this.setModal(true);

        // System.out.println("Flex: '" + flex + "'");

        this.setShadow(true);
        this.setFrame(true);
        this.setResizable(false);
        //this.setAutoWidth(true);
        //this.setAutoHeight(true);

        //this.setWidth(500);
        //this.setHeight(500);

        formPanel.setFrame(true);

        formPanel.add(testLabel);
        // Panel panel = new Panel();
        // panel.setBorder(false);
        // panel.setPaddings(15);

        this.add(formPanel);

        // System.out.println(this.getStyleName());

    }

    public void setRecord(FlexRecord flex) {
        if (true)
            return;
        final EventDisplayDialog thisDialog = this;

        this.remove(formPanel);
        formPanel = new FormPanel();

        // for (int i = 0 ; i < widgets.size(); i++) {
        // Widget widget = (Widget)widgets.remove(0);
        // }

        formPanel.setWidth(350);
        formPanel.setLabelWidth(75);

        for (int i = 0; i < flex.values.length; i++) {
            TextField field = new TextField(flex.colNames[i], flex.values[i], 230);
            field.setValue(flex.values[i]);
            field.setReadOnly(true);
            formPanel.add(field);
        }

        Button cancel = new Button("Close");
        cancel.addListener(new ButtonListenerAdapter() {
            public void onClick(Button button, EventObject obj) {
                thisDialog.hide();
            }
        });
        formPanel.addButton(cancel);

        this.add(formPanel);

        // panel.add();

    }

}
